package com.xtedu.examproject.service;

import com.xtedu.examproject.dao.base.TeacherDao;
import com.xtedu.examproject.dao.impl.TeacherDaoImpl;
import com.xtedu.examproject.entity.Teacher;
import com.xtedu.examproject.util.PageHelper;

import java.sql.SQLException;
import java.util.List;

public class TeacherService {
    private TeacherDao teacherDao;

    public TeacherService(){
        teacherDao = new TeacherDaoImpl();
    }

    public int insertTeacher(Teacher teacher) throws Exception {
        return teacherDao.insert(teacher);
    }

    public int deleteTeacher(Teacher teacher) throws Exception {
        return teacherDao.delete(teacher);
    }

    public int updateTeacher(Teacher teacher) throws Exception {
        return teacherDao.update(teacher);
    }

    public Teacher findTeacherById(int id) throws Exception {
        return teacherDao.findById(id);
    }

    public List<Teacher> findAllTeacher() throws Exception {
        return teacherDao.findAll();
    }

    public List<Teacher> findNonUserTeacher() throws Exception {
        return teacherDao.findNonUserTeacher();
    }
    public boolean deleteTeacherId(int teacherId) throws Exception {
        return teacherDao.deleteTeacherId(teacherId);
    }
    public PageHelper findAllTeacherByPage(int pageIndex, int pageSize) throws Exception {
        return teacherDao.findAllByPage(pageIndex, pageSize);
    }
    public PageHelper findTeacherById(int id, int pageIndex, int pageSize) throws Exception {
        return teacherDao.findPageIdByTeacher(id, pageIndex, pageSize);
    }
    public PageHelper findTeacherByName(String teacherName, int pageIndex, int pageSize) throws Exception {
        return teacherDao.findPageNameByTeacher(teacherName, pageIndex, pageSize);
    }
    public PageHelper findPagePhoneByTeacher(String phone, int pageIndex, int pageSize) throws Exception{
        return teacherDao.findPagePhoneByTeacher(phone, pageIndex, pageSize);
    }

    public boolean updateTeacherById(Teacher teacher) throws Exception{
        return teacherDao.updateTeacher(teacher);
    }

    public List<Teacher> findByCourseId(int courseId) throws Exception {
        return teacherDao.findTeacherByCourseId(courseId);
    }

    public PageHelper findTeacherByType(String typeName, int pageIndex, int pageSize) throws Exception {
        return teacherDao.findTeacherByType(typeName, pageIndex, pageSize);
    }
}
